<template>
    <div class="card">
        <div class="hot-title">
            <a :href="url">
                <i :class="icon"></i>
                <span class="name">{{ props.hotType?.name }}</span>
            </a>
        </div>
        <ul class="hot-content">
            <li v-for="item,index in hotSearch">
                <a :href="item.url" target="_blank">
                    <span>{{ index+1 }}.</span>
                    <span style="margin-left: 5px;">{{ item.title }}</span>
                    <span>{{ item.data }}</span>
                </a>
            </li>
        </ul>
    </div>
</template>
<script setup lang="ts">
import { HotType, HotSearch } from '../type/hotSearch';
import { getHotSearch } from '../api/hotSearch';
import { ref } from 'vue';

const props = defineProps<{
  hotType?: HotType
}>()

const url = ref()
const icon = ref()
const hotSearch = ref<HotSearch[]>() 

url.value = "/history/" + props.hotType?.en
icon.value = "iconfont icon-" + props.hotType?.en

getHotSearch(props.hotType?.en ? props.hotType.en : "weibo").then(res => {
    hotSearch.value = res.data.data
})

</script>
<style scoped>
.card {
    margin: 10px;
    padding: 20px 0;
    background-color: #fff;
    border-radius: 20px;
    transition: background-color .3s;
}
.hot-title {
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .iconfont {
        font-size: 20px;
        margin-right: 8px;
    }
    .name {
        margin-right: auto;
        font-weight: bolder;
        color: #666666;
    }
}
.hot-content {
    height: 320px;
    padding: 0 8px 0 20px;
    font-size: .82rem;
    overflow: auto;
    text-align: left;
}
ul li {
    list-style-type: none;
    margin-top: 12px;
    a {
        color: #666666;
        display: flex;
        justify-content: space-between;
        width: 100%;
        line-height: 1.3em;
        span:nth-of-type(2) {
            margin-right: auto;
            word-break: break-all;
        }
    }
}

.hot-content>li:nth-of-type(2)>a>span:first-of-type {
    color: #de6b30;
}

.hot-content>li:first-of-type>a>span:first-of-type {
    color: #cc3939;
}

.hot-content>li:nth-of-type(3)>a>span:first-of-type {
    color: #cc984f;
}
</style>